package day09API.Exception;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * @author DBX
 * @effect io流中异常处理
 * @date 2021/8/30 0030 - 10:39
 */
public class FinallyDemo1 {
    public static void main(String[] args) {
        FileReader fr = null;

        try {
            fr = new FileReader("File/log.txt");
            int b;
            while ((b = fr.read())!=-1){
                System.out.print((char)b);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (fr != null) {
                try {
                    fr.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
